/**
 * @description 
 * 程序说明：
 * @pageNo 
 * @author mlmoria
 * @date 2017年2月13日
 * 
 */
package No12Net.Chart.DIY;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.net.ServerSocket;
import java.net.Socket;

public class ChartServerDIY {
	

	public static void main(String[] args) {
		try {
			ServerSocket ss=new ServerSocket(8080);
			while(true){
			
				
				Socket socket=ss.accept();
				//InputStream is=socket.getInputStream();
				
				//readFromClient(is);
				OutputStream os=socket.getOutputStream();
				writeToClient(os);
				//is.close();
				os.close();
				//ss.close();
			}
			
			
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
/*	public static void  readFromClient(InputStream is){
		System.out.println("收到");
		Reader reader=new InputStreamReader(is);
		BufferedReader br =new BufferedReader(reader);
		String s=null;
		try {
			while((s=br.readLine())!=null){
				System.out.println("客户端说："+s);	
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}*/
	
	public static void  writeToClient(OutputStream os){
		Writer writer=new OutputStreamWriter(os);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		try {
			System.out.println("请输入：");
			String s= br.readLine();
			writer.write(s);
			br.close();
			writer.close();
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
}
